package it.koutifaris.travianmap.utils;

import it.koutifaris.travianmap.tile.TileBounds;

public class InBoundsUtil {

	public static boolean isInBounds(TileBounds bounds, int x, int y) {
		// This method is called once per map square and must be fast.
		// This is a ugly but fast version.
		int x0 = bounds.x();
		int x1 = x0 + bounds.width();
		boolean xInBounds = (x >= x0) && (x < x1);

		if (xInBounds) {
			int y0 = bounds.y();
			int y1 = y0 + bounds.height();

			return (y >= y0) && (y < y1);
		}

		return false;
	}
}
